package com.goldfish666.esp8266.util;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AirConditionerHelper {

    private static int minSize = 0;

    private static int stateCount = 0;

    private static final int TEMPERATURE_STATE_COUNT = 17;

    private static final int SPEED_STATE_COUNT = 4;

    private static final int POWER_SWITCH_STATE_COUNT = 2;

    public static void setFunction(String functionName) {

        setStateCount(functionName);

        setMaxSize();

    }

    public static int getMinSize() {
        return minSize;
    }

    public static int getStateCount() {
        return stateCount;
    }

    private static void setStateCount(String functionName) {
        switch (functionName) {
            case "temperature": {
                setTemperatureStateCount();
                break;
            }
            case "speed": {
                setSpeedStateCount();
                break;
            }
            case "powerSwitch": {
                setPowerSwitchStateCount();
                break;
            }
            default: {
                log.error("功能名错误！");
            }
        }
    }

    private static void setMaxSize() {
        minSize = 2 * stateCount;
    }

    private static void setTemperatureStateCount() {
        stateCount = TEMPERATURE_STATE_COUNT;
        log.info("当前测试功能为：温度");
    }

    private static void setSpeedStateCount() {
        stateCount = SPEED_STATE_COUNT;
        log.info("当前测试功能为：温度");
    }

    private static void setPowerSwitchStateCount() {
        stateCount = POWER_SWITCH_STATE_COUNT;
        log.info("当前测试功能为：电源开关");
    }
}
